import {
  getManageStudentList,
  addStudentClassTime,
  getStudentClassTimeDetail,
  exportStudentClassTime,
} from  '../../../service/api';
import { message } from 'antd';
export default {
  namespace: 'studentMg3',
  state: {
    studentList: {
      list: [],
      total: 0,
    },
    addClassTimeResponse: null,
    studentClassTime: {},
    exportClassTimeResponse: null,
  },

  effects: {
    *getManageStudentList({ payload }, { call, put }) {
      const response = yield call(getManageStudentList, payload);
      yield put({
        type: 'r_manageStudentList',
        payload: response,
      });
    },
    *getStudentClassTimeDetail({ payload }, { call, put }) {
      const response = yield call(getStudentClassTimeDetail, payload);
      yield put({
        type: 'r_getStudentClassTimeDetail',
        payload: response,
      });
    },
    *addStudentClassTime({ payload }, { call, put }) {
      const response = yield call(addStudentClassTime, payload);
      yield put({
        type: 'r_addStudentClassTime',
        payload: response,
      });
    },
    *exportStudentClassTime({ payload }, { call, put }) {
      const response = yield call(exportStudentClassTime, payload);
      yield put({
        type: 'r_exportStudentClassTime',
        payload: response,
      });
    },
  },

  reducers: {
    r_manageStudentList(state, action) {
      return {
        ...state,
        studentList: action.payload.data,
      };
    },
    r_getStudentClassTimeDetail(state, action) {
      return {
        ...state,
        studentClassTime: action.payload.data,
      };
    },
    r_addStudentClassTime(state, action) {
      return {
        ...state,
        addClassTimeResponse: action.payload,
      };
    },
    r_exportStudentClassTime(state, action) {
      return {
        ...state,
        exportClassTimeResponse: action.payload.data,
      };
    },
  },
};
